package com.ganbo.stock.task;

import com.ganbo.stock.config.StockJobSwitchConfig;
import com.ganbo.stock.service.impl.CompanyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时更新公司信息
 *
 * @Author: ganbo
 * @Date: 2020/12/28 13:54
 */

@Component
@Slf4j
public class CompanyJob {

    @Autowired
    CompanyService companyService;
    @Autowired
    StockJobSwitchConfig switchConfig;

    @Scheduled(cron = "*/5 * * * * ?") //5秒获取一次公司信息
    public void updateCompanyInfoTask() {
        if (switchConfig.isCompanyJob()) {
            log.info("获取公司信息 start.");
            companyService.updateCompany();
            log.info("获取公司信息 end.");
        }
    }

}
